home *** CD-ROM | disk | FTP | other *** search
- Path: news.logicon.com!newsmaster@klee
- From: kkolda@logicon.com (Kenneth D. Kolda)
- Newsgroups: comp.lang.c++
- Subject: Re: reading textfiles...
- Date: 8 Apr 1996 20:34:46 GMT
- Organization: Logicon Operating Systems
- Message-ID: <4kbt96$6jh@piper.logicon.com>
- References: <4k7p6p$i7s@netnews.upenn.edu>
- NNTP-Posting-Host: 137.51.122.161
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.2
-
- In article <4k7p6p$i7s@netnews.upenn.edu>, son@blue.seas.upenn.edu
- says...
- >
- >How do I read in a text file one line at a time?
- >
- >ifstream inFile(file, ios::in);
- >
- >inFile.get() reads in one character at a time,but how do i read a whole
- line?
- >
-
- Use istream::getline(char*, int) -- it reads to the next '\n', NULL
- terminates your string (the '\n' is NOT included in the string) and
- discards the '\n' (so you don't get it on subsequent reads).
-
- Ken Kolda
-
-
-
-
-
-
-
-
-